package com.xcity.game.worldboss.template;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;
import com.xcity.game.item.ItemInfo;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;

/**
 * 排行奖励
 * @author yang.li
 *
 */
@Excel(value = "world_boss.xlsx", sheet = 1)
public class WorldBossRankingRewardTemplate extends Template {

	/** 起始名次 */
	protected int rankingFrom;

	/** 结束名次 */
	protected int rankingTo;

	/** 奖励物品1id */
	protected int[] items;
	protected List<ItemInfo> itemsWrapped;
	
	@JSONField(serialize = false)
	@Override
	public int getId() {
		return id;
	}

	public int getRankingFrom() {
		return rankingFrom;
	}

	public void setRankingFrom(int rankingFrom) {
		this.rankingFrom = rankingFrom;
	}

	public int getRankingTo() {
		return rankingTo;
	}

	public void setRankingTo(int rankingTo) {
		this.rankingTo = rankingTo;
	}

	@JSONField(serialize = false)
	public int[] getItems() {
		return items;
	}

	public void setItems(int[] items) {
		this.items = items;
	}
	
	@JSONField(name = "items")
	public List<ItemInfo> getItemsWrapped() {
		return itemsWrapped;
	}

	@Override
	public void validate() throws TemplateException {
		itemsWrapped = new ArrayList<ItemInfo>(items.length >> 1);
		for (int i = 0; i < items.length; i += 2) {
			itemsWrapped.add(new ItemInfo(items[i], items[i + 1]));
		}
		
	}
}
